<?php 
/* Engineers: Derek Shue, Sean Margison
 * Description: Controls access to different NAV bar elements based on user type and rank
 */
	//set logged out, used to determine which options to show
    $loggedOut = true;
    $auth = Zend_Auth::getInstance(); 
    if(!$auth->hasIdentity())
    {
    }else{
		$loggedOut = false;
		$identity = $auth->getIdentity();//identity used for user type/rank decisions
    } 

 ?>

   <h2>APPLES Service-Learning</h2>
   <ul>
		<li>
	    <a href="<?php echo $this->url(array('controller'=>'index', 'action' => 'index'),'default',true) ?>">Home</a>
	    </li>
	    <?php if(!$loggedOut):?>
	   	<li>
	    	<a href="<?php echo $this->url(array('controller'=>'login','action'=>'logout'),'default',true) ?>">Logout</a>
	    </li>
		<?php endif;?>
   </ul>
 

 <?php if(!$loggedOut && $identity->getUserRank() >= 0)://profile options; available to all but display affected by user rank?>
       <h2>Profile Information</h2>
           <ul>
		   
		   
	       <li>
	           <a href="
			<?php 
			   if($identity->getUserRank() == 0)
			   echo $this->url(array('controller'=>'profile', 'action' => 'submit', 'type' => $identity->getUserType()),'default',true);
			   
			   else if($identity->getUserRank() >= 1)
			   echo $this->url(array('controller'=>'profile', 'action' => 'edit', 'type' => $identity->getUserType()),'default',true);
			   ?>
			">  
			<?php  
			    if($identity->getUserRank()==0) echo "Add Profile";
			    else if($identity->getUserRank()>=1) echo "Edit Profile";  
			?>
		    </a>
	       </li>
	       <?php if($identity->getUserRank()>0 && $identity->getUserType()=='organization'): ?>
	       <li>
	       		<a href="
	       		<?php echo $this->url(array('controller'=>'profile', 'action' => 'managecontacts'),'default',true);?>
	       		">Manage Contacts</a>
	       </li>
	       <?php endif; ?>
		   
		 
		   
		   
           </ul>
<?php endif;?>
 
 <?php if(!$loggedOut && $identity->getUserRank() >= 0): //admin options?>
			<h2>Tags</h2>
			
            <ul>
	       <?php if($identity->getUserRank() > 2): ?>
		   <li>
	           <a href="<?php echo $this->url(array('controller'=>'admin', 'action' => 'addtag'),'default',true) ?>">Manage Tags</a>
	       </li>
		    <?php endif; ?>
		  
		   <?php if($identity->getUserRank() == 1 ): ?>
		   <li>
	       <a href="<?php echo $this->url(array('controller'=>'common', 'action' => 'tags'),'default',true) ?>">View Tags</a>
	       </li>
		   <?php endif; ?>
		  
		  <ul>
 <?php endif;?>
 
<?php if(!$loggedOut && $identity->getUserRank() >= 2): //admin options?>
       <h2>Administrative Actions</h2>
           <ul>
		   <?php if(!$loggedOut && $identity->getUserRank() >= 3): //superadmin options?>
	       <li>
	           <a href="<?php echo $this->url(array('controller'=>'admin', 'action' => 'submit'),'default',true) ?>">Add User</a>
	       </li>
	       <li>
	           <a href="<?php echo $this->url(array('controller'=>'admin','action'=>'index')) ?>">View Users</a>
	       </li>
		   <?php endif;?>
	       <li>
	           <a href="<?php echo $this->url(array('controller'=>'admin','action'=>'internapp')) ?>">Review Student Internship Applications</a>
	       </li>
	       <li>
	           <a href="<?php echo $this->url(array('controller'=>'admin','action'=>'internreq')) ?>">Review Partner Internship Requests</a>
	       </li>
		   
		   <li>
	           <a href="<?php echo $this->url(array('controller'=>'admin','action'=>'managevolunteers')) ?>"> Review Course Associations</a>
	       </li>
		   
		   <li>
	           <a href="<?php echo $this->url(array('controller'=>'admin','action'=>'submitcourse')) ?>"> Add Course to Faculty</a>
	       </li>
		   
	       <li>
	           <a href="<?php echo $this->url(array('controller'=>'admin','action'=>'manageterms')) ?>">Manage Terms</a>
	       </li>
	       <li>
	           <a href="<?php echo $this->url(array('controller'=>'admin','action'=>'manageannouncements')) ?>">Manage Announcements</a>
	       </li>
           </ul>
<?php endif;?>

<?php if(!$loggedOut && $identity->getUserRank() >= 2): //admin options?>
	<h2>Administrative Queries</h2>
	       <li>
	           <a href="<?php echo $this->url(array('controller'=>'adminquery','action'=>'partner')) ?>">View Community Partners</a>
	       </li>
	       <li>
	           <a href="<?php echo $this->url(array('controller'=>'adminquery','action'=>'courses')) ?>">View Courses</a>
	       </li>
<?php endif;?>
<?php if(!$loggedOut && $identity->getUserRank() >= 2): //admin options?>
		<h2> Reports </h2>
			<ul>
		   <li>
	           <a href="<?php echo $this->url(array('controller'=>'report','action'=>'coursesreport')) ?>"> Courses Report</a>
	       </li>
		   <li>
	           <a href="<?php echo $this->url(array('controller'=>'report','action'=>'orgtocourse')) ?>"> Organization-Course Association Report</a>
	       </li>
		   <li>
	           <a href="<?php echo $this->url(array('controller'=>'report','action'=>'orghistory')) ?>"> Organization History</a>
	       </li>
		   <li>
	           <a href="<?php echo $this->url(array('controller'=>'report','action'=>'courseplacement')) ?>">Course Placement Report</a>
	       </li>
		   </ul>
		   
<?php endif;?>




<?php if(!$loggedOut && $identity->getUserType() == 'student')://student options?>
       <h2>Student</h2>
           <ul>
	       <li>
	           <a href="<?php echo $this->url(array('controller'=>'student', 'action' => 'browsecourses'),'default',true) ?>">Browse Courses</a>
	       </li>
		   
		   <li>
	           <a href="<?php echo $this->url(array('controller'=>'student', 'action' => 'browseinternships'),'default',true) ?>">Browse Internship Positions</a>
	       </li>
	       
		   <li>
		   		<?php if($identity->getUserRank() == 0): ?>
	      	   		<a href="">Apply For Internship Position</a>
	      	   <?php endif; ?>
	      	   <?php if($identity->getUserRank() > 0): ?>
	           		<a href="<?php echo $this->url(array('controller'=>'student', 'action' => 'internshipapplication'),'default',true) ?>">Apply For Internship Position</a>
	           <?php endif; ?>
	       </li>
	       <li>
	       		<?php if($identity->getUserRank() == 0): ?>
	      	   		<a href="">My Internship Applications</a>
	      	   <?php endif; ?>
	      	   <?php if($identity->getUserRank() > 0): ?>
	           		<a href="<?php echo $this->url(array('controller'=>'student', 'action' => 'myapplications'),'default',true) ?>">My Internship Applications</a>
	           <?php endif; ?>
	       </li>
		    
		   
	 
           </ul>
<?php endif;?>


<?php if(!$loggedOut && $identity->getUserType() == 'teacher'): //teacher options?>
       <h2>Faculty</h2>
           <ul>
	       <li>
	      	   <?php if($identity->getUserRank() == 0): ?>
	      	   		<a href="">My Courses</a>
	      	   <?php endif; ?>
	      	   <?php if($identity->getUserRank() > 0): ?>
	          		<a href="<?php echo $this->url(array('controller'=>'teacher', 'action' => 'mycourses'),'default',true) ?>">My Courses</a>
	           <?php endif; ?>
	       </li>
		    <li>
		    	<?php if($identity->getUserRank() == 0): ?>
	      	   		<a href="">Add Course</a>
	      	   <?php endif; ?>
	      	   <?php if($identity->getUserRank() > 0): ?>
	          		<a href="<?php echo $this->url(array('controller'=>'teacher', 'action' => 'submitcourse'),'default',true) ?>">Add Course</a>
	           <?php endif; ?>
	       </li>
		   <li>
	           <a href="<?php echo $this->url(array('controller'=>'report','action'=>'courseplacement')) ?>">Course Placement Report</a>
	       </li>
           </ul>
<?php endif;?>


<?php if(!$loggedOut && $identity->getUserType() == 'organization')://Community partner options?>
       <h2>Community Partner</h2>
           <ul>
	       <li>
	       		<?php if($identity->getUserRank() == 0): ?>
	      	   		<a href="">Service-Learning Internships</a>
	      	   <?php endif; ?>
	      	   <?php if($identity->getUserRank() > 0): ?>
	           		<a href="<?php echo $this->url(array('controller'=>'partner', 'action' => 'myinternships'),'default',true) ?>">Service-Learning Internships</a>
	           <?php endif; ?>
	       </li>
	       <li>
	       		<?php if($identity->getUserRank() == 0): ?>
	      	   		<a href="">Service-Learning Course Volunteers</a>
	      	   <?php endif; ?>
	      	   <?php if($identity->getUserRank() > 0): ?>
	           		<a href="<?php echo $this->url(array('controller'=>'partner','action'=>'myvolunteers')) ?>">Service-Learning Course Volunteers</a>
	           <?php endif; ?>
	       </li>   
		   <li>
	       		<?php if($identity->getUserRank() == 0): ?>
	      	   		<a href="">Associated Courses</a>
	      	   <?php endif; ?>
	      	   <?php if($identity->getUserRank() > 0): ?>
	           		<a href="<?php echo $this->url(array('controller'=>'report','action'=>'partnercourses')) ?>">Associated Courses</a>
	           <?php endif; ?>
	       </li>   
           </ul>
<?php endif;?>



<?php if($loggedOut)://displayed whenever logged out?>
       <h2>Login</h2>
           <ul>
	       <li>
	           <a href="<?php echo $this->url(array('controller'=>'login', 'action' => 'onyenlogin'),'default',true) ?>">Student Login</a>
	       </li>
		   <li>
	           <a href="<?php echo $this->url(array('controller'=>'login', 'action' => 'onyenlogin'),'default',true) ?>">Faculty Login</a>
	       </li>
	       <li>
	           <a href="<?php echo $this->url(array('controller'=>'login', 'action' => 'partnerlogin'),'default',true) ?>">Community Partner Login</a>
	       </li>
		   <li>
	           <a href="<?php echo $this->url(array('controller'=>'login', 'action' => 'onyenlogin'),'default',true) ?>">Administrator Login</a>
	       </li>
           </ul>
<?php endif;?>
